/*
 * @lc app=leetcode.cn id=162 lang=typescript
 *
 * [162] 寻找峰值
 */

// @lc code=start
function findPeakElement(nums: number[]): number {
  let start = 0;
  let end = nums.length - 1;
  while (start < end) {
    let mid = start + Math.floor((end - start) / 2);
    if (nums[mid] <= nums[mid + 1]) start = mid + 1;
    else end = mid;
  }
  return start;
}
// @lc code=end
